package org.jiajie.designpatterndemo.template;

/**
 * 因为声明了抽象方法，自然整个类也必须是抽象类。
 *
 * @author jay
 */
public abstract class AbstractSetting {
    public final String getSetting(String key){
        String value = lookupCache(key);
        if (value == null) {
//            value = readFromDatabase(key);
            putIntoCache(key, value);
        }
        return value;
    }
    protected abstract String lookupCache(String key);
    protected abstract void putIntoCache(String key, String value);
}
